package network.messages;

import org.json.*;

/**
 * Mensagem de setar Id de um cliente
 * @author Victor
 */
public class MensagemLogout extends Mensagem
{

	private final String FROM_ATTR = "from";
	private int _from;

	public int GetFrom()
	{
		return _from;
	}

	public void SetFrom(int from)
	{
		_from = from;
	}

	@Override
	public void Construct(JSONObject jsonObject)
	{
		try
		{
			_from = jsonObject.getInt(FROM_ATTR);
		}
		catch (JSONException err)
		{
			err.printStackTrace();
		}
	}

	@Override
	public JSONObject GetJSONObject()
	{
		JSONObject jsonObject = new JSONObject();

		try
		{
			jsonObject.put(MensagemFactory.KIND_ATTR, MensagemFactory.KIND_LOGOUT);
			jsonObject.put(FROM_ATTR, _from);
		}
		catch (JSONException err)
		{
			err.printStackTrace();
		}

		return jsonObject;
	}
}
